#!/bin/bash

export QUEC_SDK_PATH=/opt/ql-ol-sdk
export QL_SDK_PATH=${QUEC_SDK_PATH}
export QL_SDKPATH=${QUEC_SDK_PATH}
export QL_SYSROOTS=${QL_SDK_PATH}/ql-sysroots
export PATH=/opt/ql_crosstools/ql-ag35-le22-gcc640-v1-toolchain/gcc/usr/bin/arm-oe-linux-gnueabi:$PATH
export CC="arm-oe-linux-gnueabi-gcc -march=armv7-a -marm -mfpu=neon -mfloat-abi=hard --sysroot=${QL_SYSROOTS}"
export CXX="arm-oe-linux-gnueabi-g++ -march=armv7-a -marm -mfpu=neon -mfloat-abi=hard --sysroot=${QL_SYSROOTS}"
export CPP="arm-oe-linux-gnueabi-g++ -march=armv7-a -marm -mfpu=neon -mfloat-abi=hard --sysroot=${QL_SYSROOTS}"
export AR=arm-oe-linux-gnueabi-ar
export AS=arm-oe-linux-gnueabi-as
export LD=arm-oe-linux-gnueabi-ld
export NM=arm-oe-linux-gnueabi-nm
export OBJCOPY=arm-oe-linux-gnueabi-objcopy
export OBJDUMP=arm-oe-linux-gnueabi-objdump
export RANLIB=arm-oe-linux-gnueabi-ranlib
export STRIP=arm-oe-linux-gnueabi-strip
export QL_SDK_CFLAGS="-I. -I${QL_SYSROOTS}/usr/include -I${QL_SYSROOTS}/usr/include/ql_lib_utils -I${QL_SYSROOTS}/usr/include/ql-sdk"
export QL_SDK_LDFLAGS="-L. -L${QL_SYSROOTS}/lib -L${QL_SYSROOTS}/usr/lib"

rm -rf ./build
mkdir build
cd build
cmake -DUSE_TBOX=ON -DBUILD_TEST=ON ..
make -j8
